﻿using ConfExpert.Forms.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevTeam;
using System;

namespace ConfExpert.Forms.Depo
{
    public partial class HatalıToplar : XForm
    {
        public HatalıToplar()
        {
            InitializeComponent();
        }

        private void HatalıToplar_Load(object sender, EventArgs e)
        {
            
            gvRoll.Init("GetHataliToplar");
            gvRoll.OptionsBehavior.Editable = false;
            gvRoll.AddSummary("Qty");
            gvRoll.BestFitColumns();

            gvRoll.OptionsView.AllowCellMerge = true;
            gvRoll.CellMerge += new DevExpress.XtraGrid.Views.Grid.CellMergeEventHandler(gvRoll_CellMerge);
            btnGuncelle.ItemClick += btnGuncelle_ItemClick;
        }

        void btnGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvRoll.RefreshDataSource("GetHataliToplar");
        }

        void gvRoll_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
        {
            GridView view = sender as GridView;
            e.Merge = view.GetRowCellDisplayText(e.RowHandle1, e.Column) == view.GetRowCellDisplayText(e.RowHandle2, e.Column) &&
                //!e.Column.Caption.Contains("Miktar") &&
                view.GetRowCellDisplayText(e.RowHandle1, "ProductId") == view.GetRowCellDisplayText(e.RowHandle2, "ProductId");

            e.Handled = true;
        }
    }
}